package image;

import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;

/**
 * A class that allows for drawing and manipulating an ellipse
 * @author Etienne Bruines
 * @author Bas Dobbelsteen
 */
public class Ellipse extends Layer
{
	private javafx.scene.shape.Ellipse ellipse;
	
	public Ellipse(String t, Paint fore, Paint back, double strokeWidth, double x, double y, double width, double height)
	{
		super(t);
		ellipse = new javafx.scene.shape.Ellipse(x, y, width, height);
		ellipse.setFill(back);
		ellipse.setStroke(fore);
		ellipse.setStrokeWidth(strokeWidth);
		
		super.setBinding();
	}
	
	@Override public Node getContent()
	{
		return ellipse;
	}

	@Override public int getWidth()
	{
		return (int)(ellipse.getRadiusX() * 2);
	}

	@Override public int getHeight()
	{
		return (int)(ellipse.getRadiusY() * 2);
	}

	@Override public int getX()
	{
		return (int)(ellipse.getCenterX() - 0.5 * getWidth());
	}

	@Override public int getY()
	{
		return (int)(ellipse.getCenterY() - 0.5 * getHeight());
	}

	@Override public void setBorder(Color c)
	{
		this.ellipse.setStroke(c);
	}

	@Override public void setBackground(Color c)
	{
		this.ellipse.setFill(c);
	}

	@Override public void setStroke(double width)
	{
		this.ellipse.setStrokeWidth(width);
	}
}
